package com.ln.lnzw.base;

import android.app.Activity;
import android.content.Context;
import android.view.MotionEvent;
import android.view.View;

import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;

/**
 * Created by wuwei on 2017/12/26.
 */
public class BaseFragment extends  SupportFragment {
    public BaseActivity activity;


    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        this.activity = (BaseActivity) activity;
    }

    /**
     * 获取加载成功的View，由于每个子类成功的View不一样，所以应该由子类去实现
     *
     * @return
     */
    protected View getSuccessView() {
        return null;
    }

    /**
     * 请求数据的方法，应该由每个子类自己去实现
     *
     * @return
     */
    protected Object requestData() {
        return null;
    }

    public boolean onInterceptTouchEvent(MotionEvent ev) {
        // TODO Auto-generated method stub
        return true;
    }
    private CompositeDisposable compositeDisposable;

    public void addDisposable(Disposable disposable) {
        if (compositeDisposable == null) {
            compositeDisposable = new CompositeDisposable();
        }
        compositeDisposable.add(disposable);
    }

    public void dispose() {
        if (compositeDisposable != null) compositeDisposable.dispose();
    }

}
